#include "Subsystems/BlockBehaviors/SubsystemWaterPlantBlockBehavior.h"
#include "Subsystems/SubsystemTerrain.h"

#include "Blocks/DirtBlock.h"
#include "Blocks/SandBlock.h"
#include "Blocks/ClayBlock.h"

namespace PocketSurvival
{
    void SubsystemWaterPlantBlockBehavior::onNeighborBlockChanged(int32_t x, int32_t y, int32_t z, int32_t neighborX, int32_t neighborY, int32_t neighborZ)
    {
        SubsystemInWaterBlockBehavior::onNeighborBlockChanged(x, y, z, neighborX, neighborY, neighborZ);
        int32_t num  = Terrain::ExtractContents(subsystemTerrain->getCellValue(x, y, z));
        int32_t num2 = Terrain::ExtractContents(subsystemTerrain->getCellValue(x, y - 1, z));
        if (num2 != DirtBlock::Index() && num2 != SandBlock::Index() && num2 != ClayBlock::Index() && num2 != num)
        {
            subsystemTerrain->destroyCell(0, x, y, z, 0, false);
        }
    }

    static const std::string subsystemName = "WaterPlantBlockBehavior";
    const std::string& SubsystemWaterPlantBlockBehavior::getName() const
    {
        return subsystemName;
    }

} // namespace PocketSurvival

